const Router = require('koa-router');

const momentRouter = new Router({ prefix: '/moment'});
const {
  create,
  detail,
  list,
  update,
  remove,
  addLabels,
  fileInfo
} = require('../controller/moment.controller');
const {
  verifyAuth,
  verifyPermission
} = require('../middleware/auth.middleware');
const {
  verifyLabelExists
} = require('../middleware/label.middleware');
// 创建文章
momentRouter.post('/', verifyAuth, create);
// 单个文章
momentRouter.get('/:momentId', detail);
// 文章列表
momentRouter.get('/', list);
// 1. 用户必须登录 2. 用户具备权限
momentRouter.patch('/:momentId', verifyAuth, verifyPermission, update);

momentRouter.delete('/:momentId', verifyAuth, verifyPermission, remove);

// 给动态添加标签接口
momentRouter.post('/:momentId/labels', verifyAuth, verifyPermission, verifyLabelExists, addLabels)
// 动态配图
momentRouter.get('/images/:filename', fileInfo);

module.exports = momentRouter;


